package com.windoent.yugioh.adapter.brvah;

import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.windoent.yugioh.R;
import com.windoent.yugioh.bean.ChangeRoleBean;

/**
 * author : robert
 * date   : 2021/5/6 15:26
 * desc   :
 */
public class ChangeRoleAdapter extends BaseQuickAdapter<ChangeRoleBean, BaseViewHolder> {

    private int position = 0;

    public ChangeRoleAdapter() {
        super(R.layout.item_chaneg_role, null);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ChangeRoleBean item) {
        helper.setText(R.id.tv_name, item.getName());
        ImageView view = helper.getView(R.id.image);
        CheckBox checkBox = helper.getView(R.id.check_box);
        view.setBackgroundResource(item.getRes());
        int layoutPosition = helper.getLayoutPosition();
        checkBox.setChecked(layoutPosition == position);
    }

    public void setDefaultCheck(int position) {
        this.position = position;
    }
}